package com.tanhua.manage.service;


import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import com.tanhua.manage.api.PublishApi;
import com.tanhua.manage.vo.PageInfo;
import com.tanhua.manage.vo.PageResult;
import com.tanhua.manage.vo.PublishDetailsVo;
import com.tanhua.manage.vo.PublishInfoVo;
import org.bson.types.ObjectId;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Properties;

@Service
public class PublishInfoService {


    @Autowired
    private PublishApi publishApi;

    public PageResult queryPublishList(Integer page, Integer pageSize, String sortProrerties, String sortOrder,
                                       ObjectId publishId, Integer userId, String startDate, String endDate) {

        PageInfo<PublishInfoVo> publishInfoVoPageInfo =
                this.publishApi.queryPublishInfo(page, pageSize, sortProrerties,
                                                  publishId, userId, startDate, endDate);
        PageResult pageResult = new PageResult();
        pageResult.setPage(page);
        pageResult.setPagesize(pageSize);
        if (ObjectUtil.isEmpty(publishInfoVoPageInfo)){
            pageResult.setItems(publishInfoVoPageInfo.getRecords());
            // TODO  状态未返回



            return pageResult;
        }

        return pageResult;


    }

    /**
     *   查询圈子详细信息
     * @param publishId  圈子id
     * @return
     */
    public PublishDetailsVo queryPublishDetails(String publishId) {

        PublishDetailsVo publishDetailsVo = this.publishApi.queryPublishDetails(publishId);
        return publishDetailsVo;

    }
}
